package top.guoyang.springboot3.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.guoyang.springboot3.base.PageBean;
import top.guoyang.springboot3.base.R;
import top.guoyang.springboot3.entity.TbSoftwareType;
import top.guoyang.springboot3.service.TbSoftwareTypeService;
import top.guoyang.springboot3.vo.PageVO;

import java.util.List;

@RestController
@RequestMapping("/softwareType")
@RequiredArgsConstructor
public class TbSoftwareTypeController {
    private final TbSoftwareTypeService tbSoftwareTypeService;


//    @GetMapping("/queryAll")
//    public R<PageVO<TbSoftwareType>> queryAll(PageBean pageBean, TbSoftwareType tbSoftwareType) {
//        return tbSoftwareTypeService.queryPage(pageBean, tbSoftwareType);
//    }

    @GetMapping("/{pn}/{ps}")
    public R<PageVO<TbSoftwareType>> queryPage(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize, TbSoftwareType tbSoftwareType) {
        return tbSoftwareTypeService.queryPage(PageBean.instance(pageNumber, pageSize), tbSoftwareType);
    }

    @PostMapping("")
    public R<String> insert(@RequestBody TbSoftwareType tbSoftwareType) {
        return tbSoftwareTypeService.insert(tbSoftwareType);
    }

//    @GetMapping("")
//    public R<List<TbSoftwareType>> query(TbSoftwareType tbSoftwareType) {
//        return tbSoftwareTypeService.query(tbSoftwareType);
//    }

    @GetMapping("/{id}")
    public R<TbSoftwareType> queryById(@PathVariable("id") Integer id) {
        return tbSoftwareTypeService.queryById(id);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbSoftwareType tbSoftwareType) {
        return tbSoftwareTypeService.update(tbSoftwareType);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbSoftwareTypeService.delete(id);
    }
}
